Skip to content

Conversation

Lsimmons98
Copy link

Used state to populate shopping list based on drop down menu and toggle light and dark mode.

// replace 'false' with a state variable that can be toggled between true and false
// this will be used for the Dark Mode Toggle feature
const appClass = false ? "App dark" : "App light"
const [count, setCount] = useState(false)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you think of a better name than count? What is really being stored in that variable?

Comment on lines +5 to +6
const updateClass = count ? 'in-cart' : ''
const updateButtonText = count ? 'Remove From Cart' : 'Add to Cart'

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When you prefix with update, that implies that something is updated. While that's kind of true in this case, it's not entirely true and there is a better name. Something like itemClass implies that it will be returning a a class name for the item, and buttonClass is less redundant. It's subjective, but what do you think?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants